Home > Java Programming > Flow Control > Questions and Answers
01. |
What will be the output of the program? int I = 0;
outer: while (true) { I++; inner: for (int j = 0; j < 10; j++) { I += j; if (j == 3) continue inner; break outer; } continue outer; } System.out.println(I); | |||||||||||
|
02. |
What will be the output of the program? int i = O;
while(1) { if(i == 4) { break; } ++i; } System.out.println("i = " + i); | |||||||||||
|
03. |
What will be the output of the program? for(int i = 0; i < 3; i++)
{ switch(i) { case 0: break; case 1: System.out.print("one "); case 2: System.out.print("two "); case 3: System.out.print("three "); } } System.out.println("done"); | |||||||||||
|
04. |
public class While { public void loop() { int x= 0; while ( 1 ) /* Line 6 */ { System.out.print("x plus one is " + (x + 1)); /* Line 8 */ } } } Which statement is true? | |||||||||||
|
05. |
class A{ Public static void main(String args[]){ System.out.println(“I am in main methodâ€); } Public static void test(){ System.out.println(“I am in test methodâ€); } } Which is true?
| |||||||||||
|
06. |
class A{ Public static void test(){ System.out.println(“I am in test methodâ€); } Public static void main(String args[]){ System.out.println(“I am in main methodâ€); } Public static void test1(){ System.out.println(“I am in test methodâ€); } } Which will print the output?
| |||||||||||
|
07. |
class F{ public static void main(String args[]){ Int i=10; System.out.println(“value of I isâ€+i); } } | |||||||||||
|
08. |
class F { Static public void main(String args[]) { System.out.println(“HIâ€); } } | |||||||||||
|
09. |
class F { public void main(String args[]) { System.out.println(“HIâ€); } } | |||||||||||
|
10. |
class F{ static void main(String args[]){ System.out.println(“HIâ€); } } | |||||||||||
|